﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Reflection;

namespace SPFeatureGenerator
{
    public static class Utils
    {
        /*
         * validate a textBox, returns true when correct, false when incorrect
         */ 
        public static bool validateTextBox(TextBox edit)
        {
            if (edit.Text.Trim().Length == 0)
            {
                edit.BackColor = Color.Yellow;
                return false;
            }
            else
            {
                edit.BackColor = Color.White;
                return true;
            }
        }

        /**
         * Get the string from an embedded resource file.
         */
        public static string getResource(string filename)
        {
            using (StreamReader sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("SPFeatureGenerator.resources.xml." + filename)))
            {
                return sr.ReadToEnd();
            }
        }
    }
}
